Skip to content

fix: validate player squad numbers#612

Open
kriptoburak wants to merge 2 commits into
nanotaboada:masterfrom
kriptoburak:codex/positive-squad-number-0844
Open

fix: validate player squad numbers#612
kriptoburak wants to merge 2 commits into
nanotaboada:masterfrom
kriptoburak:codex/positive-squad-number-0844

Conversation

@kriptoburak

@kriptoburak kriptoburak commented Jul 2, 2026

Copy link
Copy Markdown

Summary

  • require player squad numbers to be positive in the request model
  • add a regression test for zero squad numbers

Validation

  • targeted player route test suite passed

This change is Reviewable

Summary by CodeRabbit

  • Bug Fixes
    • Player submissions now reject invalid squad numbers of 0 or below, improving input validation.
    • The API returns a clear validation error when an invalid squad number is provided.
  • Tests
    • Added coverage for rejecting player requests with an invalid squad number.
    • Updated test cleanup comments for consistency.

@coderabbitai

coderabbitai Bot commented Jul 2, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 51cc0e86-0bff-4707-9d5b-242f35029ca4

📥 Commits

Reviewing files that changed from the base of the PR and between bb21092 and e09daef.

📒 Files selected for processing (1)
  • models/player_model.py
🚧 Files skipped from review as they are similar to previous changes (1)
  • models/player_model.py

Walkthrough

PlayerRequestModel.squad_number now uses Pydantic validation to require values greater than zero, and the test suite adds coverage for a 422 response when zero is submitted. Minor docstring and comment text edits were also made.

Changes

Squad Number Validation

Layer / File(s) Summary
Field constraint and validation test
models/player_model.py, tests/test_main.py
squad_number now uses Field(gt=0) validation, and a POST test asserts that squad_number = 0 returns 422; associated docstring and comment dash edits are included.

Estimated code review effort: 1 (Trivial) | ~5 minutes

🚥 Pre-merge checks | ✅ 2
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title uses Conventional Commits, stays under 80 characters, and accurately describes the squad number validation change.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • 🛠️ sync documentation
  • 🛠️ enforce http error handling
  • 🛠️ idiomatic review
  • 🛠️ verify api contract

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
models/player_model.py (1)

51-64: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Consider documenting the new constraint.

The squad_number attribute docstring still reads as a plain unique identifier; a brief mention that it must be positive would keep the docstring in sync with the Field(gt=0) constraint.

📝 Suggested docstring tweak
-        squad_number (int): The unique squad number assigned to the Player.
+        squad_number (int): The unique, positive squad number assigned to the
+        Player.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@models/player_model.py` around lines 51 - 64, The Player model docstring for
squad_number is missing the new positivity constraint, so update the attribute
description in Player to note that squad_number must be a positive unique squad
number. Keep the wording in sync with the Field(gt=0) validation on the
squad_number field, and adjust the surrounding docstring text in
models.player_model.Player accordingly.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@models/player_model.py`:
- Around line 51-64: The Player model docstring for squad_number is missing the
new positivity constraint, so update the attribute description in Player to note
that squad_number must be a positive unique squad number. Keep the wording in
sync with the Field(gt=0) validation on the squad_number field, and adjust the
surrounding docstring text in models.player_model.Player accordingly.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: b010168e-7801-48ad-996e-c99d5839f49b

📥 Commits

Reviewing files that changed from the base of the PR and between 700194d and bb21092.

📒 Files selected for processing (2)
  • models/player_model.py
  • tests/test_main.py

@kriptoburak kriptoburak changed the title Validate player squad numbers fix: validate player squad numbers Jul 2, 2026
@sonarqubecloud

sonarqubecloud Bot commented Jul 2, 2026

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant